package com.demo.webflux.feigncore;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.demo.Student;
import com.alibaba.dubbo.demo.Teacher;

@RestController
public class FeignController {
	private static Logger logger = LoggerFactory.getLogger(FeignController.class);

	@GetMapping("/sen/{owner}/{age}")
	public List<Student> contributors(@PathVariable("owner") String owner, @PathVariable("age") Integer age){
		logger.info("------");
		List<Student> list = new ArrayList<>();
		list.add(new Student(owner, age));
		return list;
	}

	@PostMapping("/sen2")
	public List<Student> contributors2(@RequestBody List<Student> students, @RequestHeader("token") String token){
		System.out.println("------" + token);
		System.out.println("------" + students);
		students.add(new Student("test", 100));
		return students;
	}

	@PostMapping("/sen3")
	public Teacher contributors3(@RequestBody Teacher teacher, @RequestHeader("token") String token){
		System.out.println("------" + token);
		System.out.println("------" + teacher);
		return teacher;
	}

	@PostMapping("/sen4")
	public List<Teacher> contributors4(@RequestBody List<Teacher> students, @RequestHeader("token") String token){
		System.out.println("------" + token);
		System.out.println("------" + students);
		students.add(new Teacher("test", "4"));
		return students;
	}

}
